<!DOCTYPE html>
<html lang="zh-CN" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Vagrant 操作 | 静思田园</title>
    <meta name="description" content="时不时记录一点点">
    <meta name="generator" content="VitePress v1.5.0">
    <link rel="preload stylesheet" href="/assets/style.D1KHeDuB.css" as="style">
    <link rel="preload stylesheet" href="/vp-icons.css" as="style">
    <script type="module" src="/assets/chunks/metadata.d4b76d32.js"></script>
    <script type="module" src="/assets/app.Cqoht_Of.js"></script>
    <link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
    <link rel="modulepreload" href="/assets/chunks/framework.trnLO_3_.js">
    <link rel="modulepreload" href="/assets/chunks/theme.BNMYWj-o.js">
    <link rel="modulepreload" href="/assets/chunks/katex.BZy9Y_85.js">
    <link rel="modulepreload" href="/assets/chunks/c4Diagram-3d4e48cf.rhyfUO3k.js">
    <link rel="modulepreload" href="/assets/chunks/flowDiagram-66a62f08.BvVfKYLl.js">
    <link rel="modulepreload" href="/assets/chunks/flowDiagram-v2-96b9c2cf.rYAPEXyw.js">
    <link rel="modulepreload" href="/assets/chunks/erDiagram-9861fffd.CQSbaoJM.js">
    <link rel="modulepreload" href="/assets/chunks/gitGraphDiagram-72cf32ee.CjLmC8RV.js">
    <link rel="modulepreload" href="/assets/chunks/ganttDiagram-c361ad54.R_V-FeK5.js">
    <link rel="modulepreload" href="/assets/chunks/infoDiagram-f8f76790.C-2Va9KZ.js">
    <link rel="modulepreload" href="/assets/chunks/pieDiagram-8a3498a8.B9ZVkD7K.js">
    <link rel="modulepreload" href="/assets/chunks/quadrantDiagram-120e2f19.BuonnDHi.js">
    <link rel="modulepreload" href="/assets/chunks/xychartDiagram-e933f94c.C_bIYaUn.js">
    <link rel="modulepreload" href="/assets/chunks/requirementDiagram-deff3bca.RFVzvdjl.js">
    <link rel="modulepreload" href="/assets/chunks/sequenceDiagram-704730f1.UZWxMlyq.js">
    <link rel="modulepreload" href="/assets/chunks/classDiagram-70f12bd4.sipmPMFa.js">
    <link rel="modulepreload" href="/assets/chunks/classDiagram-v2-f2320105.CDkLxQ0T.js">
    <link rel="modulepreload" href="/assets/chunks/stateDiagram-587899a1.CD2ocVZB.js">
    <link rel="modulepreload" href="/assets/chunks/stateDiagram-v2-d93cdb3a.D0qUPm3J.js">
    <link rel="modulepreload" href="/assets/chunks/journeyDiagram-49397b02.CeUUZA2l.js">
    <link rel="modulepreload" href="/assets/chunks/flowchart-elk-definition-4a651766.DkdgpMTf.js">
    <link rel="modulepreload" href="/assets/chunks/timeline-definition-85554ec2.WL9yxus9.js">
    <link rel="modulepreload" href="/assets/chunks/mindmap-definition-fc14e90a.CWC2bxmB.js">
    <link rel="modulepreload" href="/assets/chunks/sankeyDiagram-04a897e0.BXj8OViR.js">
    <link rel="modulepreload" href="/assets/chunks/blockDiagram-38ab4fdb.CPVnJXk5.js">
    <link rel="modulepreload" href="/assets/chunks/virtual_mermaid-config.DDnGl6nM.js">
    <link rel="modulepreload" href="/assets/tools_vagrant_use.md.B9T2WJ1x.lean.js">
    <meta name="application-name" content="VuePress">
    <meta name="apple-mobile-web-app-title" content="静思田园">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="msapplication-TileColor" content="#3eaf7c">
    <meta name="theme-color" content="#646cff">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
    <script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-5d98c3a5><!--[--><!--]--><!--[--><span tabindex="-1" data-v-0f60ec36></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0f60ec36> Skip to content </a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar" data-v-ae24b3ad data-v-6aa21345><div class="wrapper" data-v-6aa21345><div class="container" data-v-6aa21345><div class="title" data-v-6aa21345><div class="VPNavBarTitle has-sidebar" data-v-6aa21345 data-v-1168a8e4><a class="title" href="/" data-v-1168a8e4><!--[--><!--]--><!--[--><img class="VPImage logo" src="/logo.png" alt data-v-8426fc1a><!--]--><span data-v-1168a8e4>静思田园</span><!--[--><!--]--></a></div></div><div class="content" data-v-6aa21345><div class="content-body" data-v-6aa21345><!--[--><!--]--><div class="VPNavBarSearch search" data-v-6aa21345><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="搜索文档"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">搜索文档</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-6aa21345 data-v-dc692963><span id="main-nav-aria-label" class="visually-hidden" data-v-dc692963> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57></span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/network/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>网络工程师</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/frontend/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>前端</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/English/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>English</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/Scrupy/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>爬虫</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/backend/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>后端</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/bigdata/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>大数据</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/computer/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>计算机基础</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/database/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>数据库</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/docker/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>dorker</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/git/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>Git</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/nodejs/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>Node.js</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/python/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>Python</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/shell/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>shell</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/tools/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>工具</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-6aa21345 data-v-6c893767><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-6c893767 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-6aa21345 data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/loveagri" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><span class="vpi-social-github"></span></a><a class="VPSocialLink no-icon" href="https://gitee.com/loveagri" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>码云</title><path d="M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.016 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.592.592 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296Z"/></svg></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-6aa21345 data-v-bb2aa2f0 data-v-cf11d7a2><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-cf11d7a2><span class="vpi-more-horizontal icon" data-v-cf11d7a2></span></button><div class="menu" data-v-cf11d7a2><div class="VPMenu" data-v-cf11d7a2 data-v-b98bc113><!----><!--[--><!--[--><!----><div class="group" data-v-bb2aa2f0><div class="item appearance" data-v-bb2aa2f0><p class="label" data-v-bb2aa2f0>Appearance</p><div class="appearance-action" data-v-bb2aa2f0><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-bb2aa2f0 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div></div></div><div class="group" data-v-bb2aa2f0><div class="item social-links" data-v-bb2aa2f0><div class="VPSocialLinks social-links-list" data-v-bb2aa2f0 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/loveagri" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><span class="vpi-social-github"></span></a><a class="VPSocialLink no-icon" href="https://gitee.com/loveagri" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>码云</title><path d="M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.016 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.592.592 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296Z"/></svg></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-6aa21345 data-v-e5dd9c1c><span class="container" data-v-e5dd9c1c><span class="top" data-v-e5dd9c1c></span><span class="middle" data-v-e5dd9c1c></span><span class="bottom" data-v-e5dd9c1c></span></span></button></div></div></div></div><div class="divider" data-v-6aa21345><div class="divider-line" data-v-6aa21345></div></div></div><!----></header><div class="VPLocalNav has-sidebar empty" data-v-5d98c3a5 data-v-a6f0e41e><div class="container" data-v-a6f0e41e><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-a6f0e41e><span class="vpi-align-left menu-icon" data-v-a6f0e41e></span><span class="menu-text" data-v-a6f0e41e>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-a6f0e41e data-v-17a5e62e><button data-v-17a5e62e>Return to top</button><!----></div></div></div><aside class="VPSidebar" data-v-5d98c3a5 data-v-319d5ca6><div class="curtain" data-v-319d5ca6></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-319d5ca6><span class="visually-hidden" id="sidebar-aria-label" data-v-319d5ca6> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 has-active" data-v-c40bc020 data-v-b7550ba0><div class="item" role="button" tabindex="0" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><h2 class="text" data-v-b7550ba0>vagrant</h2><!----></div><div class="items" data-v-b7550ba0><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/tools/vagrant/" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>vagrant</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/tools/vagrant/sync.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>vagrant文件同步</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/tools/vagrant/use.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>Vagrant 操作</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-5d98c3a5 data-v-1428d186><div class="VPDoc has-sidebar has-aside" data-v-1428d186 data-v-39a288b8><!--[--><!--]--><div class="container" data-v-39a288b8><div class="aside" data-v-39a288b8><div class="aside-curtain" data-v-39a288b8></div><div class="aside-container" data-v-39a288b8><div class="aside-content" data-v-39a288b8><div class="VPDocAside" data-v-39a288b8 data-v-3f215769><!--[--><!--]--><!--[--><!--]--><nav aria-labelledby="doc-outline-aria-label" class="VPDocAsideOutline" data-v-3f215769 data-v-a5bbad30><div class="content" data-v-a5bbad30><div class="outline-marker" data-v-a5bbad30></div><div aria-level="2" class="outline-title" id="doc-outline-aria-label" role="heading" data-v-a5bbad30>目录</div><ul class="VPDocOutlineItem root" data-v-a5bbad30 data-v-b933a997><!--[--><!--]--></ul></div></nav><!--[--><!--]--><div class="spacer" data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-39a288b8><div class="content-container" data-v-39a288b8><!--[--><!--]--><main class="main" data-v-39a288b8><div style="position:relative;" class="vp-doc _tools_vagrant_use" data-v-39a288b8><div><h1 id="vagrant-操作" tabindex="-1">Vagrant 操作 <a class="header-anchor" href="#vagrant-操作" aria-label="Permalink to &quot;Vagrant 操作&quot;">​</a></h1><h3 id="任何目录登录vagrant" tabindex="-1">任何目录登录vagrant <a class="header-anchor" href="#任何目录登录vagrant" aria-label="Permalink to &quot;任何目录登录vagrant&quot;">​</a></h3><p>讲如下内容复制到.ssh文件夹下，并命名为<em>config</em>，然后就可以在任何目录通过<code>ssh vagrant-host</code>登录主机了</p><div class="language-yaml line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#98C379;">Host vagrant-host</span></span>
<span class="line"><span style="color:#98C379;">  HostName 127.0.0.1</span></span>
<span class="line"><span style="color:#98C379;">  User vagrant</span></span>
<span class="line"><span style="color:#98C379;">  Port 2222</span></span>
<span class="line"><span style="color:#98C379;">  UserKnownHostsFile /dev/null</span></span>
<span class="line"><span style="color:#98C379;">  StrictHostKeyChecking no</span></span>
<span class="line"><span style="color:#98C379;">  PasswordAuthentication no</span></span>
<span class="line"><span style="color:#98C379;">  IdentityFile /Users/press/Vagrant/.vagrant/machines/default/virtualbox/private_key</span></span>
<span class="line"><span style="color:#98C379;">  IdentitiesOnly yes</span></span>
<span class="line"><span style="color:#98C379;">  LogLevel FATAL</span></span>
<span class="line"><span style="color:#98C379;">  PubkeyAcceptedKeyTypes +ssh-rsa</span></span>
<span class="line"><span style="color:#98C379;">  HostKeyAlgorithms +ssh-rsa</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><h2 id="vagrantfile配置" tabindex="-1">Vagrantfile配置 <a class="header-anchor" href="#vagrantfile配置" aria-label="Permalink to &quot;Vagrantfile配置&quot;">​</a></h2><h3 id="基础vagrangtfile配置" tabindex="-1">基础Vagrangtfile<a href="https://www.cnblogs.com/super-lulu/p/11347086.html" target="_blank" rel="noreferrer">配置</a> <a class="header-anchor" href="#基础vagrangtfile配置" aria-label="Permalink to &quot;基础Vagrangtfile[配置](https://www.cnblogs.com/super-lulu/p/11347086.html)&quot;">​</a></h3><div class="language-ruby line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ruby</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E5C07B;">Vagrant</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">configure</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&quot;2&quot;</span><span style="color:#ABB2BF;">) </span><span style="color:#C678DD;">do</span><span style="color:#ABB2BF;"> |</span><span style="color:#E06C75;">config</span><span style="color:#ABB2BF;">|</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">   # hostname设置</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">hostname</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &quot;node1&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">  # 必须先禁用默认的同步目录，否则会报错，原因未知！！！,开启此行就可以不用安装vagrant-vbguest</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">synced_folder</span><span style="color:#98C379;"> &#39;.&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;/vagrant&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">disabled</span><span style="color:#D19A66;">:</span><span style="color:#D19A66;"> true</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">  # 同步目录设置,实时同步采用默认方式即可，rsync不起作用</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">synced_folder</span><span style="color:#98C379;"> &quot;D:/xxx/code&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;/home/www/&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">  # 端口转发设置</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">network</span><span style="color:#98C379;"> &quot;forwarded_port&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">guest</span><span style="color:#D19A66;">:</span><span style="color:#D19A66;"> 80</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">host</span><span style="color:#D19A66;">:</span><span style="color:#D19A66;"> 8080</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">host_ip</span><span style="color:#D19A66;">:</span><span style="color:#98C379;"> &quot;127.0.0.1&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">  # host-only</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">network</span><span style="color:#98C379;"> &quot;private_network&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">ip</span><span style="color:#D19A66;">:</span><span style="color:#98C379;"> &quot;192.168.33.10&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">  # 创建一个bridge桥接网络，指定IP</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">network</span><span style="color:#98C379;"> &quot;public_network&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">ip</span><span style="color:#D19A66;">:</span><span style="color:#98C379;"> &quot;192.168.0.200&quot;</span></span>
<span class="line"><span style="color:#ABB2BF;">  </span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">provider</span><span style="color:#98C379;"> &quot;virtualbox&quot;</span><span style="color:#C678DD;"> do</span><span style="color:#ABB2BF;"> |</span><span style="color:#E06C75;">vb</span><span style="color:#ABB2BF;">|</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">     # 指定vm-name，也就是virtualbox管理控制台中的虚机名称。如果不指定该选项会生成一个随机的名字，不容易区分。</span></span>
<span class="line"><span style="color:#ABB2BF;">    vb.</span><span style="color:#61AFEF;">name</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &quot;centos7&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">    # vagrant up启动时，是否自动打开virtual box的窗口，缺省为false</span></span>
<span class="line"><span style="color:#ABB2BF;">    vb.</span><span style="color:#61AFEF;">gui</span><span style="color:#56B6C2;"> =</span><span style="color:#D19A66;"> true</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">    # 指定vm内存，单位为MB</span></span>
<span class="line"><span style="color:#ABB2BF;">    vb.</span><span style="color:#61AFEF;">memory</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &quot;4096&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">    # 设置CPU个数</span></span>
<span class="line"><span style="color:#ABB2BF;">    vb.</span><span style="color:#61AFEF;">cpus</span><span style="color:#56B6C2;"> =</span><span style="color:#D19A66;"> 2</span></span>
<span class="line"><span style="color:#ABB2BF;">    </span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">    #修改vb.name的值</span></span>
<span class="line"><span style="color:#ABB2BF;">    vb.</span><span style="color:#61AFEF;">customize</span><span style="color:#ABB2BF;"> [</span><span style="color:#98C379;">&quot;modifyvm&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">id</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;--name&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;mfsmaster2&quot;</span><span style="color:#ABB2BF;">]</span></span>
<span class="line"><span style="color:#ABB2BF;">     </span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">    #如修改显存，缺省为8M，如果启动桌面，至少需要10M，如下修改为16M：</span></span>
<span class="line"><span style="color:#ABB2BF;">    vb.</span><span style="color:#61AFEF;">customize</span><span style="color:#ABB2BF;"> [</span><span style="color:#98C379;">&quot;modifyvm&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">id</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;--vram&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;16&quot;</span><span style="color:#ABB2BF;">]</span></span>
<span class="line"><span style="color:#ABB2BF;">     </span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">    #调整虚拟机的内存</span></span>
<span class="line"><span style="color:#ABB2BF;">    vb.</span><span style="color:#61AFEF;">customize</span><span style="color:#ABB2BF;"> [</span><span style="color:#98C379;">&quot;modifyvm&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">id</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;--memory&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;1024&quot;</span><span style="color:#ABB2BF;">]</span></span>
<span class="line"><span style="color:#ABB2BF;">     </span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">    #指定虚拟CPU个数</span></span>
<span class="line"><span style="color:#ABB2BF;">    vb.</span><span style="color:#61AFEF;">customize</span><span style="color:#ABB2BF;"> [</span><span style="color:#98C379;">&quot;modifyvm&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">id</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;--cpus&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;2&quot;</span><span style="color:#ABB2BF;">]</span></span>
<span class="line"><span style="color:#ABB2BF;">     </span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">    #增加光驱：</span></span>
<span class="line"><span style="color:#ABB2BF;">    vb.</span><span style="color:#61AFEF;">customize</span><span style="color:#ABB2BF;"> [</span><span style="color:#98C379;">&quot;storageattach&quot;</span><span style="color:#ABB2BF;">,</span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">id</span><span style="color:#ABB2BF;">,</span><span style="color:#98C379;">&quot;--storagectl&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;IDE Controller&quot;</span><span style="color:#ABB2BF;">,</span><span style="color:#98C379;">&quot;--port&quot;</span><span style="color:#ABB2BF;">,</span><span style="color:#98C379;">&quot;0&quot;</span><span style="color:#ABB2BF;">,</span><span style="color:#98C379;">&quot;--device&quot;</span><span style="color:#ABB2BF;">,</span><span style="color:#98C379;">&quot;0&quot;</span><span style="color:#ABB2BF;">,</span><span style="color:#98C379;">&quot;--type&quot;</span><span style="color:#ABB2BF;">,</span><span style="color:#98C379;">&quot;dvddrive&quot;</span><span style="color:#ABB2BF;">,</span><span style="color:#98C379;">&quot;--medium&quot;</span><span style="color:#ABB2BF;">,</span><span style="color:#98C379;">&quot;/Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso&quot;</span><span style="color:#ABB2BF;">]</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">    #注：meduim参数不可以为空，如果只挂载驱动器不挂在iso，指定为“emptydrive”。如果要卸载光驱，medium传入none即可。</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">    #从这个指令可以看出，customize方法传入一个json数组，按照顺序传入参数即可。 json数组传入多个参数</span></span>
<span class="line"><span style="color:#ABB2BF;">    vb.</span><span style="color:#61AFEF;">customize</span><span style="color:#ABB2BF;"> [</span><span style="color:#98C379;">&quot;modifyvm&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">id</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;--name&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;mfsserver3&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;--memory&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;2048&quot;</span><span style="color:#ABB2BF;">]</span></span>
<span class="line"><span style="color:#ABB2BF;">    </span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">    # 单个机器执行脚本</span></span>
<span class="line"><span style="color:#ABB2BF;">    vb.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">provision</span><span style="color:#D19A66;"> :</span><span style="color:#56B6C2;">shell</span><span style="color:#C678DD;"> do</span><span style="color:#ABB2BF;"> |</span><span style="color:#E06C75;">shell</span><span style="color:#ABB2BF;">|</span></span>
<span class="line"><span style="color:#ABB2BF;">      shell.</span><span style="color:#61AFEF;">path</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &quot;db.sh&quot;</span></span>
<span class="line"><span style="color:#C678DD;">    end</span></span>
<span class="line"><span style="color:#C678DD;">	end</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">  # 初始脚本</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">  # 外置文件初始脚本</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">provision</span><span style="color:#98C379;"> &quot;shell&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">privileged</span><span style="color:#D19A66;">:</span><span style="color:#D19A66;"> true</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">path</span><span style="color:#D19A66;">:</span><span style="color:#98C379;"> &quot;./setup.sh&quot;</span></span>
<span class="line"><span style="color:#ABB2BF;">  </span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">  # 行内样式</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">provision</span><span style="color:#98C379;"> &quot;shell&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">inline</span><span style="color:#D19A66;">:</span><span style="color:#98C379;"> &quot;sudo apt-get update; sudo ln -sf /usr/bin/python3 /usr/bin/python&quot;</span></span>
<span class="line"><span style="color:#ABB2BF;">  </span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">  # 块输入</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">provision</span><span style="color:#98C379;"> &quot;shell&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">inline</span><span style="color:#D19A66;">:</span><span style="color:#98C379;"> &lt;&lt;-SHELL</span></span>
<span class="line"><span style="color:#61AFEF;">    apt-get</span><span style="color:#98C379;"> update</span></span>
<span class="line"><span style="color:#61AFEF;">    apt-get</span><span style="color:#98C379;"> install </span><span style="color:#D19A66;">-y</span><span style="color:#98C379;"> nginx</span></span>
<span class="line"><span style="color:#98C379;">  SHELL</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ABB2BF;">	 </span></span>
<span class="line"><span style="color:#C678DD;">end</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br></div></div><div class="language-ruby line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ruby</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E5C07B;">Vagrant</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">configure</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&quot;2&quot;</span><span style="color:#ABB2BF;">) </span><span style="color:#C678DD;">do</span><span style="color:#ABB2BF;"> |</span><span style="color:#E06C75;">config</span><span style="color:#ABB2BF;">|</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">box</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &quot;centos/7&quot;</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">hostname</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &quot;vagrant-demo&quot;</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">box_version</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &quot;2004.01&quot;</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">define</span><span style="color:#98C379;"> &quot;web-server&quot;</span><span style="color:#C678DD;"> do</span><span style="color:#ABB2BF;"> |</span><span style="color:#E06C75;">web</span><span style="color:#ABB2BF;">| </span><span style="color:#7F848E;font-style:italic;"># virtualbox name</span></span>
<span class="line"><span style="color:#ABB2BF;">    web.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">hostname</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &quot;web&quot;</span><span style="color:#7F848E;font-style:italic;"> # hostname</span></span>
<span class="line"><span style="color:#C678DD;">  end</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">define</span><span style="color:#98C379;"> &quot;database&quot;</span><span style="color:#C678DD;"> do</span><span style="color:#ABB2BF;"> |</span><span style="color:#E06C75;">db</span><span style="color:#ABB2BF;">|</span></span>
<span class="line"><span style="color:#ABB2BF;">    db.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">hostname</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &quot;db&quot;</span></span>
<span class="line"><span style="color:#C678DD;">  end</span></span>
<span class="line"><span style="color:#C678DD;">end</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><h3 id="循环vagrangtfile配置" tabindex="-1">循环Vagrangtfile配置 <a class="header-anchor" href="#循环vagrangtfile配置" aria-label="Permalink to &quot;循环Vagrangtfile配置&quot;">​</a></h3><p>setup.sh：</p><div class="language-sh line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#7F848E;font-style:italic;">#/bin/sh</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"># install some tools</span></span>
<span class="line"><span style="color:#61AFEF;">sudo</span><span style="color:#98C379;"> yum</span><span style="color:#98C379;"> install</span><span style="color:#D19A66;"> -y</span><span style="color:#98C379;"> git</span><span style="color:#98C379;"> vim</span><span style="color:#98C379;"> gcc</span><span style="color:#98C379;"> glibc-static</span><span style="color:#98C379;"> telnet</span><span style="color:#98C379;"> bridge-utils</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"># install docker</span></span>
<span class="line"><span style="color:#61AFEF;">curl</span><span style="color:#D19A66;"> -fsSL</span><span style="color:#98C379;"> get.docker.com</span><span style="color:#D19A66;"> -o</span><span style="color:#98C379;"> get-docker.sh</span></span>
<span class="line"><span style="color:#61AFEF;">sh</span><span style="color:#98C379;"> get-docker.sh</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"># start docker service</span></span>
<span class="line"><span style="color:#61AFEF;">sudo</span><span style="color:#98C379;"> groupadd</span><span style="color:#98C379;"> docker</span></span>
<span class="line"><span style="color:#61AFEF;">sudo</span><span style="color:#98C379;"> gpasswd</span><span style="color:#D19A66;"> -a</span><span style="color:#98C379;"> vagrant</span><span style="color:#98C379;"> docker</span></span>
<span class="line"><span style="color:#61AFEF;">sudo</span><span style="color:#98C379;"> systemctl</span><span style="color:#98C379;"> start</span><span style="color:#98C379;"> docker</span></span>
<span class="line"></span>
<span class="line"><span style="color:#61AFEF;">rm</span><span style="color:#D19A66;"> -rf</span><span style="color:#98C379;"> get-docker.sh</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><p>Vagrantfile：</p><div class="language-ruby line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ruby</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#7F848E;font-style:italic;"># -*- mode: ruby -*-</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;"># vi: set ft=ruby :</span></span>
<span class="line"></span>
<span class="line"><span style="color:#E5C07B;">Vagrant</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">require_version</span><span style="color:#98C379;"> &quot;&gt;= 1.6.0&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#E06C75;">boxes</span><span style="color:#ABB2BF;"> = [</span></span>
<span class="line"><span style="color:#ABB2BF;">    {</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">name</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;gitlab&quot;</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">eth1</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;192.168.211.10&quot;</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">mem</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;4096&quot;</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">cpu</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;2&quot;</span></span>
<span class="line"><span style="color:#ABB2BF;">    },</span></span>
<span class="line"><span style="color:#ABB2BF;">    {</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">name</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;gitlab-ci&quot;</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">eth1</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;192.168.211.11&quot;</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">mem</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;1024&quot;</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">cpu</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;1&quot;</span></span>
<span class="line"><span style="color:#ABB2BF;">    },</span></span>
<span class="line"><span style="color:#ABB2BF;">    {</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">name</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;k8s-master&quot;</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">eth1</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;192.168.211.20&quot;</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">mem</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;2048&quot;</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">cpu</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;1&quot;</span></span>
<span class="line"><span style="color:#ABB2BF;">    },</span></span>
<span class="line"><span style="color:#ABB2BF;">    {</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">name</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;k8s-node&quot;</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">eth1</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;192.168.211.21&quot;</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">mem</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;2048&quot;</span><span style="color:#ABB2BF;">,</span></span>
<span class="line"><span style="color:#D19A66;">        :</span><span style="color:#56B6C2;">cpu</span><span style="color:#ABB2BF;"> =&gt; </span><span style="color:#98C379;">&quot;1&quot;</span></span>
<span class="line"><span style="color:#ABB2BF;">    },    </span></span>
<span class="line"><span style="color:#ABB2BF;">]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#E5C07B;">Vagrant</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">configure</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">2</span><span style="color:#ABB2BF;">) </span><span style="color:#C678DD;">do</span><span style="color:#ABB2BF;"> |</span><span style="color:#E06C75;">config</span><span style="color:#ABB2BF;">|</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">box</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &quot;centos/7&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ABB2BF;">  boxes.</span><span style="color:#61AFEF;">each</span><span style="color:#C678DD;"> do</span><span style="color:#ABB2BF;"> |</span><span style="color:#E06C75;">opts</span><span style="color:#ABB2BF;">|</span></span>
<span class="line"><span style="color:#ABB2BF;">      config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">define</span><span style="color:#ABB2BF;"> opts[</span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">name</span><span style="color:#ABB2BF;">] </span><span style="color:#C678DD;">do</span><span style="color:#ABB2BF;"> |</span><span style="color:#E06C75;">config</span><span style="color:#ABB2BF;">|</span></span>
<span class="line"><span style="color:#ABB2BF;">        config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">hostname</span><span style="color:#56B6C2;"> =</span><span style="color:#ABB2BF;"> opts[</span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">name</span><span style="color:#ABB2BF;">]</span></span>
<span class="line"><span style="color:#ABB2BF;">        config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">provider</span><span style="color:#98C379;"> &quot;vmware_fusion&quot;</span><span style="color:#C678DD;"> do</span><span style="color:#ABB2BF;"> |</span><span style="color:#E06C75;">v</span><span style="color:#ABB2BF;">|</span></span>
<span class="line"><span style="color:#ABB2BF;">          v.</span><span style="color:#61AFEF;">vmx</span><span style="color:#ABB2BF;">[</span><span style="color:#98C379;">&quot;memsize&quot;</span><span style="color:#ABB2BF;">] </span><span style="color:#56B6C2;">=</span><span style="color:#ABB2BF;"> opts[</span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">mem</span><span style="color:#ABB2BF;">]</span></span>
<span class="line"><span style="color:#ABB2BF;">          v.</span><span style="color:#61AFEF;">vmx</span><span style="color:#ABB2BF;">[</span><span style="color:#98C379;">&quot;numvcpus&quot;</span><span style="color:#ABB2BF;">] </span><span style="color:#56B6C2;">=</span><span style="color:#ABB2BF;"> opts[</span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">cpu</span><span style="color:#ABB2BF;">]</span></span>
<span class="line"><span style="color:#C678DD;">        end</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ABB2BF;">        config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">provider</span><span style="color:#98C379;"> &quot;virtualbox&quot;</span><span style="color:#C678DD;"> do</span><span style="color:#ABB2BF;"> |</span><span style="color:#E06C75;">v</span><span style="color:#ABB2BF;">|</span></span>
<span class="line"><span style="color:#ABB2BF;">          v.</span><span style="color:#61AFEF;">customize</span><span style="color:#ABB2BF;"> [</span><span style="color:#98C379;">&quot;modifyvm&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">id</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;--memory&quot;</span><span style="color:#ABB2BF;">, opts[</span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">mem</span><span style="color:#ABB2BF;">]]</span></span>
<span class="line"><span style="color:#ABB2BF;">          v.</span><span style="color:#61AFEF;">customize</span><span style="color:#ABB2BF;"> [</span><span style="color:#98C379;">&quot;modifyvm&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">id</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;--cpus&quot;</span><span style="color:#ABB2BF;">, opts[</span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">cpu</span><span style="color:#ABB2BF;">]]</span></span>
<span class="line"><span style="color:#C678DD;">        end</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ABB2BF;">        config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">network</span><span style="color:#D19A66;"> :</span><span style="color:#56B6C2;">private_network</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">ip</span><span style="color:#D19A66;">:</span><span style="color:#ABB2BF;"> opts[</span><span style="color:#D19A66;">:</span><span style="color:#56B6C2;">eth1</span><span style="color:#ABB2BF;">]</span></span>
<span class="line"><span style="color:#C678DD;">      end</span></span>
<span class="line"><span style="color:#C678DD;">  end</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">synced_folder</span><span style="color:#98C379;"> &quot;./labs&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&quot;/home/vagrant/labs&quot;</span></span>
<span class="line"><span style="color:#ABB2BF;">  config.</span><span style="color:#61AFEF;">vm</span><span style="color:#ABB2BF;">.</span><span style="color:#61AFEF;">provision</span><span style="color:#98C379;"> &quot;shell&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">privileged</span><span style="color:#D19A66;">:</span><span style="color:#D19A66;"> true</span><span style="color:#ABB2BF;">, </span><span style="color:#56B6C2;">path</span><span style="color:#D19A66;">:</span><span style="color:#98C379;"> &quot;./setup.sh&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C678DD;">end</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br></div></div></div></div></main><footer class="VPDocFooter" data-v-39a288b8 data-v-e257564d><!--[--><!--]--><div class="edit-info" data-v-e257564d><!----><div class="last-updated" data-v-e257564d><p class="VPLastUpdated" data-v-e257564d data-v-e98dd255>最后更新: <time datetime="2024-12-30T14:20:32.000Z" data-v-e98dd255></time></p></div></div><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-e257564d><span class="visually-hidden" id="doc-footer-aria-label" data-v-e257564d>Pager</span><div class="pager" data-v-e257564d><a class="VPLink link pager-link prev" href="/tools/vagrant/sync.html" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>上一篇</span><span class="title" data-v-e257564d>vagrant文件同步</span><!--]--></a></div><div class="pager" data-v-e257564d><!----></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>
    
    
  </body>
</html>